#pragma once
#pragma execution_character_set("utf-8")

#include "XPWidgets.h"
#include "XPStandardWidgets.h"
#include "XPLMCamera.h"
#include "XPLMGraphics.h"
#include "XPLMProcessing.h"
#include "XPLMUtilities.h"
#include "XPLMDataAccess.h"
#include <stdio.h>
#include <vector>
#include <string>
#include "fileparse.h"

using namespace std;

#define LOCATION_INPUT_MAX 6
#define LOCATION_BUTTON_MAX 5
#define LOCATION_FILE_PATH "./Resources/plugins/Xplane-Control/location.txt"

extern int sceneryMenuCreateFlag;
extern XPWidgetID sceneryWidgetID;

struct location {
	
	double lat;
	double lon;
	double height;
	double heading;
	double pitch;
	double roll;
};

void initSceneryLocation();
inline	float	HACKFLOAT(float val);
void createSceneryWidget(int x, int y, int width, int height);
int positionHandler(XPWidgetMessage inMessage, XPWidgetID inWidget, intptr_t inParam1, intptr_t inParam2);
void operateLocation(int type);
void showCurrentLocation();
void locationEditToSwitchVar();
void switchCurrentLocation();
int myOrbitPlaneFunc(XPLMCameraPosition_t* outCameraPosition, int inIsLosingControl, void* inRefcon);
float enableFreeCamera(float elapsedMe, float elapsedSim, int counter, void* refcon);
void showSwitchLocation();
void saveCurrentEditLocation();
void remoteControlSceneryLocation(char recvBuf[], int length);
double chars2Double(char chs[]);
void switchLastLocation();
